﻿namespace uTorrentNAS.Services
{
    using Utilities;

    public class ConfigurationService
    {
        private readonly Serializer<Configuration> _serializer;
        public ConfigurationService(Serializer<Configuration> serializer)
        {
            _serializer = serializer;
        }

        public Configuration Retrieve()
        {
            try
            {
                return _serializer.DeserializeObject();
            }
            catch
            {
                return null;
            }
        }

        public void Save(Configuration configuration)
        {
            _serializer.SerializeObject(configuration);
        }
    }
}
